// https://www.luogu.com.cn/problem/P1856
#include <algorithm>
#include <cstring>
#include <iostream>
using namespace std;
using ll = long long;
using T = int;
T rad(); // quick read
const int inf = 0x3f3f3f3f;
#define rf(i, n) for (int i = 1; i <= (n); ++i)
const int max_size = 5 + 2e4;
const int maxn = 5 + 5e3;

int n;
int x_1[maxn], x_2[maxn], y_1[maxn], y_2[maxn];
int esiz;
pair<int, int> event[maxn << 1]; // 存储事件，frist 是事件的发生时间，second 是事件类型

int cov[max_size << 2];                    // 子区间被完整覆盖了多少次
int val[max_size << 2];                    // 子区间的非 0 段数
bool lt[max_size << 2], rt[max_size << 2]; // 左右端点标记
/*
区间 +- 1
求非 0 段数
维护段数、左右端点
*/

void maintain(int u, int l, int r) {
    if (cov[u]) { // 之前已经被覆盖
        val[u] = 1, lt[u] = 1, rt[u] = 1;
        return;
    }
    if (l == r) { // cov[u] == 0，叶子特判
        val[u] = 0, lt[u] = 0, rt[u] = 0;
        return;
    }
    val[u] = val[u << 1] + val[u << 1 | 1] - (rt[u << 1] & lt[u << 1 | 1]);
    lt[u] = lt[u << 1];
    rt[u] = rt[u << 1 | 1];
}

void update(int u, int l, int r, int s, int t, int x) {
    if (s <= l && r <= t) {
        cov[u] += x;
        maintain(u, l, r); // 注意合并
        return;
    }
    // push_down(u, l, r);
    int mid = l + r >> 1;
    if (s <= mid) update(u << 1, l, mid, s, t, x);
    if (t > mid) update(u << 1 | 1, mid + 1, r, s, t, x);
    maintain(u, l, r);
}

int ask() { return val[1]; }

ll solve() {
    memset(lt, false, sizeof(lt));
    memset(rt, false, sizeof(rt));
    memset(val, 0, sizeof(val));
    memset(cov, 0, sizeof(cov));
    esiz = 0;
    rf(i, n) {
        event[esiz++] = {x_1[i], +i}; // 正数事件是插入 i
        event[esiz++] = {x_2[i], -i}; // 负数事件是删除 -i
    }
    sort(event, event + esiz);
    ll ans = 0, last = event[0].first;
    for (int j = 0; j < esiz; ++j) {
        // puts("g");
        ans += (event[j].first - last) * (ll)ask() * 2, last = event[j].first;
        int i = event[j].second;
        if (i > 0) // 进入
            update(1, 0, max_size, y_1[i] + 1, y_2[i], 1);
        else // 离开
            update(1, 0, max_size, y_1[-i] + 1, y_2[-i], -1);
    }
    return ans;
}

int main() {
    n = rad();
    rf(i, n) { x_1[i] = rad() + 1e4, y_1[i] = rad() + 1e4, x_2[i] = rad() + 1e4, y_2[i] = rad() + 1e4; }
    ll ans = 0;
    ans += solve();
    rf(i, n) { swap(x_1[i], y_1[i]), swap(x_2[i], y_2[i]); }
    ans += solve();
    printf("%lld", ans);
}

T rad() {
    T back = 0;
    int ch = 0, posi = 0;
    for (; ch < '0' || ch > '9'; ch = getchar())
        posi = ch ^ '-';
    for (; ch >= '0' && ch <= '9'; ch = getchar())
        back = (back << 1) + (back << 3) + (ch & 0xf);
    return posi ? back : -back;
}